<template>
    <view>
        <view class="main" :style="'background:' + color" v-if="kpggimg.length == 0">
            <!--<image src=""></image>-->
        </view>
        <view class="main" v-if="kpggimg.length > 0">
            <swiper :circular="true" class="swiper" duration="500" indicatorActiveColor="#34AAFF" indicatorColor="white" :indicatorDots="true" interval="5000">
                <swiper-item @tap="tzweb" :data-index="index" v-for="(item, index) in kpggimg" :key="item.unique">
                    <image
                        v-if="item.logo!=''"
                        @tap="jumps"
                        class="img"
                        :data-appid="item.appid"
                        :data-id="item.id"
                        :data-name="item.title"
                        :data-src="item.src"
                        :data-type="item.item"
                        :data-wb_src="item.src2"
                        :src="item.logo"
                    ></image>
                </swiper-item>
            </swiper>
            <view @tap="tggg" class="tggg">
                <text :style="'color:' + color + ';margin-right:10rpx;font-size:26rpx;'">({{ second }}s)</text>
                跳过
            </view>
        </view>
    </view>
</template>

<script>
var dsq;
var dsq1;
var app = getApp();
export default {
    data() {
        return {
            second: 3,
            fxzuid: '',
            xtxx: '',
            kpggimg: [],
            color: ''
        };
    },
    onLoad(e){
        console.log("页面加载onload",e);
        var that = this;
        var t = decodeURIComponent(e.scene);
        console.log('scene', t);
        if ('undefined' != t) {
            var n = t;
        }
        if (null != e.userid) {
            console.log('转发获取到的userid:', e.userid);
            n = e.userid;
        }
        console.log('fxzuid', n);
        this.setData({
            fxzuid: n
        });
        app.globalData.getUserInfo(function (e) {
            console.log(e);
            if (null != n) {
                app.globalData.util.request({
                    url: 'entry/wxapp/Binding',
                    cachetime: '0',
                    data: {
                        fx_user: e.id,
                        user_id: n
                    },
                    success: function (e) {
                        console.log(e);
                    }
                });
            } else {
                app.globalData.util.request({
                    url: 'entry/wxapp/Binding',
                    cachetime: '0',
                    data: {
                        fx_user: e.id,
                        user_id: 0
                    },
                    success: function (e) {
                        console.log(e);
                    }
                });
            }
        });
        app.globalData.setNavigationBarColor(this);
        app.globalData.util.request({
            url: 'entry/wxapp/system',
            cachetime: '0',
            success: function (e) {
                var t = Number(e.data.countdown);
                dsq = setInterval(function () {
                    t--;
                    that.setData({
                        second: t
                    });
                }, 1000);
                dsq1 = setTimeout(function () {
                    clearInterval(dsq);
                    that.tggg();
                }, 1000 * t);
                var n = e.data;
                console.log("系统数据", n)
                that.setData({
                    xtxx: n,
                    second: e.data.countdown
                });
                getApp().globalData.xtxx1 = n;
                uni.setNavigationBarTitle({
                    title: e.data.url_name
                });
                app.globalData.util.request({
                    url: 'entry/wxapp/ad',
                    cachetime: '0',
                    data: {
                        type: '2'
                    },
                    success: function (e) {
                        if (0 == e.data.length && 0 < t) {
                            clearInterval(dsq);
                            clearTimeout(dsq1);
                            setTimeout(function () {
                                if ('1' == n.model) {
                                    uni.reLaunch({
                                        url: '/ymq_canyino2o/pages/index/index'
                                    });
                                }
                                if ('2' == n.model) {
                                    getApp().globalData.sjid = n.default_store;
                                    uni.reLaunch({
                                        url: '/ymq_canyino2o/pages/seller/index'
                                    });
                                }
                                if ('3' == n.model) {
                                    uni.reLaunch({
                                        url: '/ymq_canyino2o/pages/Liar/Liar'
                                    });
                                }
                                if ('4' == n.model) {
                                    getApp().globalData.sjid = n.default_store;
                                    uni.reLaunch({
                                        url: '/ymq_canyino2o/pages/seller/indextakeout'
                                    });
                                }
                            }, 0);
                        }
                        that.setData({
                            kpggimg: e.data
                        });
                    }
                });
            }
        });
    },
    onReady: function () {},
    onShow: function () {},
    onHide: function () {},
    onUnload: function () {},
    onPullDownRefresh: function () {},
    onReachBottom: function () {},
    onShareAppMessage: function () {},
    methods: {
        tggg: function () {
            console.log('tggg');
            clearInterval(dsq);
            clearTimeout(dsq1);
            var e = this.xtxx;
            if ('1' == e.model) {
                uni.reLaunch({
                    url: '/ymq_canyino2o/pages/index/index'
                });
            }
            if ('2' == e.model) {
                getApp().globalData.sjid = e.default_store;
                uni.reLaunch({
                    url: '/ymq_canyino2o/pages/seller/index'
                });
            }
            if ('3' == e.model) {
                uni.reLaunch({
                    url: '/ymq_canyino2o/pages/Liar/Liar'
                });
            }
            if ('4' == e.model) {
                getApp().globalData.sjid = e.default_store;
                uni.reLaunch({
                    url: '/ymq_canyino2o/pages/seller/indextakeout'
                });
            }
        },

        tzweb() {
            console.log('占位：函数 tzweb 未声明');
        },

        jumps() {
            console.log('占位：函数 jumps 未声明');
        }
    }
};
</script>
<style>
@import './loginindex.css';
</style>
